package com.gnerv.pabu.test.org.auto;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * 基础平台-自动化配置启动类
 * </p>
 *
 * @author Gnerv LiGen
 * @since 2019-08-18
 */
@Slf4j
@Configuration
@EnableConfigurationProperties(PabuConfigProperties.class)
@ConditionalOnProperty(prefix = "pabu", value = "enabled", matchIfMissing = true)
public class PabuAutoConfiguration {

    @Autowired
    private PabuConfigProperties pabuConfigProperties;

    @Bean
    @ConditionalOnMissingBean(Swagger2.class)//当Spring Context中有指定的Bean的条件下
    public Swagger2 swagger2(){
        Swagger2 swagger2 = new Swagger2();
        swagger2.pabuConfigProperties = pabuConfigProperties;
        return swagger2;
    }
}
